<template>
  <!-- 商品组件 -->
  <div class="goods">
    <div class="title">{{ title }}</div>
    <ul class="list">
      <li
        class="list_item"
        v-for="item in list"
        :key="item.id"
        @click="gotoDetails(item.id)"
      >
        <van-image width="100%" lazy-load :src="item.list_pic_url">
          <template v-slot:loading>
            <van-loading type="spinner" color="#1989fa" size="24" />
          </template>
        </van-image>
        <p class="name">{{ item.name }}</p>
        <p class="price">{{ $global.toYuan(item.retail_price) }}</p>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'goodsList',
  props: ['title', 'list'],
  methods: {
    gotoDetails (id) {
      this.$emit('gotoDetails', id)
    }
  }
}
</script>

<style scoped lang='less'>
.goods {
  background-color: #fff;
  .title {
    height: 0.5rem;
    line-height: 0.5rem;
    text-align: center;
    font-size: 0.2rem;
  }
  .list {
    width: 100%;
    padding: 0.1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    box-sizing: border-box;
    .list_item {
      width: 49%;
      background-color: #fff;
      text-align: center;
      margin-bottom: 0.1rem;
      padding-bottom: 0.1rem;
      .name {
        font-size: 0.14rem;
      }
      .price {
        color: #8b0000;
        margin-top: 0.05rem;
      }
    }
  }
}
</style>
